﻿@using System.Threading.Tasks
@using MVlog.Web.Areas.AppAreaName.Startup
@{
    ViewBag.CurrentPageName = AppAreaNamePageNames.Common.AuditLogs;
}

@section Styles
{
    <environment names="Development">
        <link rel="stylesheet" href="~/view-resources/Areas/AppAreaName/Views/AuditLogs/index.css" asp-append-version="true" />
    </environment>

    <environment names="Staging,Production">
        <link rel="stylesheet" href="~/view-resources/Areas/AppAreaName/Views/AuditLogs/index.min.css" asp-append-version="true" />
    </environment>
}

@section Scripts
{
    <environment names="Development">
        <script src="~/view-resources/Areas/AppAreaName/Views/AuditLogs/Index.js" asp-append-version="true"></script>
    </environment>

    <environment names="Staging,Production">
        <script src="~/view-resources/Areas/AppAreaName/Views/AuditLogs/Index.min.js" asp-append-version="true"></script>
    </environment>
}
<div class="row margin-bottom-5">
    <div class="col-xs-6">
        <div class="page-head">
            <div class="page-title">
                <h1>
                    <span>@L("AuditLogs")</span>
                </h1>
            </div>
        </div>
    </div>
    <div class="col-xs-6 text-right">

    </div>
</div>

<div class="portlet light margin-bottom-0">
    <div class="portlet-body">

        <div class="form">
            <form id="AuditLogFilterForm" class="horizontal-form">
                <div class="form-body">

                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="control-label">@L("DateRange")</label>
                                <input type="text" class="form-control date-range-picker" />
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="control-label">@L("UserName")</label>
                                <input type="text" name="UserName" class="form-control">
                            </div>
                        </div>
                    </div>

                    <div id="AdvacedAuditFiltersArea" style="display: none">

                        <div class="row">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="control-label">@L("Service")</label>
                                    <input name="ServiceName" type="text" class="form-control">
                                </div>
                            </div>
                            <div class="col-md-6">
                                <label class="control-label" style="display: block">@L("Duration")</label>
                                <div class="input-group" style="width: 250px !important;">
                                    <input type="number" name="MinExecutionDuration" only-number="" class="form-control" min="0" max="86400000" ng-minlength="0" ng-maxlength="8">
                                    <span class="input-group-addon">
                                        ---
                                    </span>
                                    <input type="number" name="MaxExecutionDuration" only-number="" class="form-control" min="0" max="86400000" ng-minlength="0" ng-maxlength="8">
                                </div>
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="control-label">@L("Action")</label>
                                    <input type="text" name="MethodName" class="form-control">
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="control-label">@L("ErrorState")</label>
                                    <select name="HasException" class="form-control">
                                        <option value="">@L("All")</option>
                                        <option value="false">@L("Success")</option>
                                        <option value="true">@L("HasError")</option>
                                    </select>
                                </div>
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="control-label">@L("Browser")</label>
                                    <input type="text" name="BrowserInfo" class="form-control" ng-model="vm.requestParams.browserInfo">
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">

                                </div>
                            </div>
                        </div>

                    </div>

                </div>
                <div class="row margin-bottom-10">
                    <div class="col-sm-6">
                        <span id="ShowAdvancedFiltersSpan" class="clickable-item text-muted"><i class="fa fa-angle-down"></i> @L("ShowAdvancedFilters")</span>
                        <span id="HideAdvancedFiltersSpan" class="clickable-item text-muted" style="display: none"><i class="fa fa-angle-up"></i> @L("HideAdvancedFilters")</span>
                    </div>
                    <div class="col-sm-6 text-right">
                        <button id="ExportAuditLogsToExcelButton" class="btn green-haze"><i class="fa fa-file-excel-o"></i> @L("ExportToExcel")</button>
                        <button id="RefreshAuditLogsButton" class="btn blue"><i class=" fa fa-refresh"></i> @L("Refresh")</button>
                    </div>
                </div>
            </form>
        </div>
        <table id="AuditLogsTable" class="display table table-striped table-bordered table-hover dt-responsive nowrap">
            <thead>
            <tr>
                <th></th>
                <th></th>
                <th>@L("Time")</th>
                <th>@L("UserName")</th>
                <th>@L("Service")</th>
                <th>@L("Action")</th>
                <th>@L("Duration")</th>
                <th>@L("IpAddress")</th>
                <th>@L("Client")</th>
                <th>@L("Browser")</th>
            </tr>
            </thead>
        </table>
    </div>
</div>

<div class="modal fade" id="AuditLogDetailModal" tabindex="-1" role="modal" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title">
                    <span ng-if="!vm.user.id">@L("AuditLogDetail")</span>
                </h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal audit-log-detail-view" role="form">
                    <div class="form-body">
                        <h3 class="form-section">@L("UserInformations")</h3>
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="control-label col-sm-3">@L("UserName"):</label>
                                    <div class="col-sm-9">
                                        <p class="form-control-static">
                                            <span id="AuditLogDetailModal_UserName"></span>
                                        </p>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-sm-3">@L("IpAddress"):</label>
                                    <div class="col-sm-9">
                                        <p class="form-control-static">
                                            <span id="AuditLogDetailModal_ClientIpAddress"></span>
                                        </p>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-sm-3">@L("Client"):</label>
                                    <div class="col-sm-9">
                                        <p class="form-control-static">
                                            <span id="AuditLogDetailModal_ClientName"></span>
                                        </p>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-sm-3">@L("Browser"):</label>
                                    <div class="col-sm-9">
                                        <p class="form-control-static">
                                            <span id="AuditLogDetailModal_BrowserInfo"></span>
                                        </p>
                                    </div>
                                </div>
                                <div id="AuditLogDetailModal_ImpersonatorInfo" class="form-group">
                                    <label class="control-label col-sm-3"></label>
                                    <div class="col-sm-9">
                                        <p class="form-control-static text-warning">
                                            @L("AuditLogImpersonatedOperationInfo")
                                        </p>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <h3 class="form-section">@L("ActionInformations")</h3>
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="control-label col-sm-3">@L("Service"):</label>
                                    <div class="col-sm-9">
                                        <p class="form-control-static">
                                            <span id="AuditLogDetailModal_ServiceName"></span>
                                        </p>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="control-label col-sm-3">@L("Action"):</label>
                                    <div class="col-sm-9">
                                        <p class="form-control-static">
                                            <span id="AuditLogDetailModal_MethodName"></span>
                                        </p>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="control-label col-sm-3">@L("Time"):</label>
                                    <div class="col-sm-9">
                                        <p class="form-control-static">
                                            <span id="AuditLogDetailModal_ExecutionTime"></span>
                                        </p>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="control-label col-sm-3">@L("Duration"):</label>
                                    <div class="col-sm-9">
                                        <p class="form-control-static">
                                            <span id="AuditLogDetailModal_Duration"></span>
                                        </p>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-sm-3">@L("Parameters"):</label>
                                    <div class="col-sm-9">
                                        <pre lang="js" id="AuditLogDetailModal_Parameters"></pre>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <h3 class="form-section">@L("CustomData")</h3>
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <div class="col-sm-12">
                                        <p class="form-control-static" id="AuditLogDetailModal_CustomData_None">
                                            @L("None")
                                        </p>
                                        <pre id="AuditLogDetailModal_CustomData"></pre>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <h3 class="form-section">@L("ErrorState")</h3>
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <div class="col-sm-12">
                                        <p id="AuditLogDetailModal_Success" class="form-control-static">
                                            <i class="fa fa-check-circle font-green"></i> @L("Success")
                                        </p>
                                        <pre id="AuditLogDetailModal_Exception"></pre>
                                    </div>
                                </div>
                            </div>
                        </div>

                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">@L("Close")</button>
            </div>
        </div>
    </div>
</div>